<template>
  <!--  开关-->
  <el-switch v-if="!config.isSearch"
             v-model="localValue"
             :disabled="config.disabled||false"
             active-color="#13ce66"
             inactive-color="#ff4949"
             :active-value="config.active||'Y'"
             :inactive-value="config.inactive||'N'">
  </el-switch>
  <el-select v-else-if="config.isSearch"
             v-model="localValue"
             style="width: 100%"
             clearable
             placeholder="全部"
             :multiple="false"
             :disabled="config.disabled||false"
  >
    <el-option
      v-for="item in [{label:'是',value:config.active},{label:'否',value:config.inactive}]"
      :key="item.value"
      :label="item.label"
      :value="item.value"
    ></el-option>
  </el-select>
</template>

<script>
export default {
  name: "config-switch",
  props: {
    value: String,
    config: {
      type: Object,
      default: {}
    },
  },
  computed: {
    localValue: {
      get() {
        return this.value;
      },
      set(newValue) {
        this.$emit('updateValue', newValue);
      }
    }
  },
  methods: {
    // updateValue(value) {
    //   this.$emit('updateValue', value);
    // }
  }
}
</script>

<style scoped>

</style>
